package com.wuhunyu.controller;

import com.wuhunyu.commonutils.result.CommonResult;
import com.wuhunyu.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 视频管理控制器
 *
 * @author wuhunyu
 * @version 1.0
 * @date 2021-01-20 14:39
 */
@RestController
@RequestMapping("/video")
//@CrossOrigin
public class VideoController {

    @Autowired
    private VideoService videoService;

    @PostMapping("/addVideo")
    public CommonResult addVideo(MultipartFile file) {
        return videoService.addVideo(file);
    }

    @GetMapping("/getVideo/{videoId}")
    public CommonResult getVideo(@PathVariable("videoId") String videoId) {
        return videoService.getVideo(videoId);
    }

    @DeleteMapping("/deleteVideo/{videoId}")
    public CommonResult deleteVideo(@PathVariable("videoId") String videoId) {
        return videoService.deleteVideo(videoId);
    }

    @DeleteMapping("/deleteVideos")
    public CommonResult deleteVideos(@RequestBody(required = false) List<String> ids) {
        return videoService.deleteVideos(ids);
    }

    @GetMapping("/getPlayAuth/{videoId}")
    public CommonResult getPlayAuth(@PathVariable("videoId") String videoId) {
        return videoService.getPlayAuth(videoId);
    }

}
